/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: 
 * License Type: Evaluation
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Com_precioDAOImpl implements orm.dao.Com_precioDAO {
	public Com_precio loadCom_precioByORMID(java.util.Date pre_id_precio) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return loadCom_precioByORMID(session, pre_id_precio);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio getCom_precioByORMID(java.util.Date pre_id_precio) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return getCom_precioByORMID(session, pre_id_precio);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio loadCom_precioByORMID(java.util.Date pre_id_precio, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return loadCom_precioByORMID(session, pre_id_precio, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio getCom_precioByORMID(java.util.Date pre_id_precio, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return getCom_precioByORMID(session, pre_id_precio, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio loadCom_precioByORMID(PersistentSession session, java.util.Date pre_id_precio) throws PersistentException {
		try {
			return (Com_precio) session.load(orm.Com_precio.class, pre_id_precio);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio getCom_precioByORMID(PersistentSession session, java.util.Date pre_id_precio) throws PersistentException {
		try {
			return (Com_precio) session.get(orm.Com_precio.class, pre_id_precio);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio loadCom_precioByORMID(PersistentSession session, java.util.Date pre_id_precio, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Com_precio) session.load(orm.Com_precio.class, pre_id_precio, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio getCom_precioByORMID(PersistentSession session, java.util.Date pre_id_precio, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Com_precio) session.get(orm.Com_precio.class, pre_id_precio, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio[] listCom_precioByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return listCom_precioByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio[] listCom_precioByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return listCom_precioByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio[] listCom_precioByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Com_precio as Com_precio");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Com_precio[]) list.toArray(new Com_precio[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio[] listCom_precioByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Com_precio as Com_precio");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Com_precio[]) list.toArray(new Com_precio[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio loadCom_precioByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return loadCom_precioByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio loadCom_precioByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return loadCom_precioByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio loadCom_precioByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Com_precio[] com_precios = listCom_precioByQuery(session, condition, orderBy);
		if (com_precios != null && com_precios.length > 0)
			return com_precios[0];
		else
			return null;
	}
	
	public Com_precio loadCom_precioByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Com_precio[] com_precios = listCom_precioByQuery(session, condition, orderBy, lockMode);
		if (com_precios != null && com_precios.length > 0)
			return com_precios[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateCom_precioByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return iterateCom_precioByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateCom_precioByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return iterateCom_precioByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateCom_precioByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Com_precio as Com_precio");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateCom_precioByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Com_precio as Com_precio");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio createCom_precio() {
		return new orm.Com_precio();
	}
	
	public boolean save(orm.Com_precio com_precio) throws PersistentException {
		try {
			orm.Prueba1PersistentManager.instance().saveObject(com_precio);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Com_precio com_precio) throws PersistentException {
		try {
			orm.Prueba1PersistentManager.instance().deleteObject(com_precio);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Com_precio com_precio) throws PersistentException {
		try {
			orm.Prueba1PersistentManager.instance().getSession().refresh(com_precio);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Com_precio com_precio) throws PersistentException {
		try {
			orm.Prueba1PersistentManager.instance().getSession().evict(com_precio);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_precio loadCom_precioByCriteria(Com_precioCriteria com_precioCriteria) {
		Com_precio[] com_precios = listCom_precioByCriteria(com_precioCriteria);
		if(com_precios == null || com_precios.length == 0) {
			return null;
		}
		return com_precios[0];
	}
	
	public Com_precio[] listCom_precioByCriteria(Com_precioCriteria com_precioCriteria) {
		return com_precioCriteria.listCom_precio();
	}
}
